<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item><a href="/">电影管理</a></el-breadcrumb-item>
      <el-breadcrumb-item>电影列表</el-breadcrumb-item>
      <el-breadcrumb-item>剧照列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 分割线 -->
    <el-divider></el-divider>
    <el-divider content-position="left">演员列表</el-divider>
    <div v-if="thumbList">
      <div class="thumb-item" v-for="item in thumbList" :key="item.id">
        <el-image
          style="
            width: 160px;
            height: 120px;
            box-shadow: #0003 5px 5px 5px 0px;
            margin: 10px 20px 0px 0px;
          "
          :src="item.url"
          fit="cover"
        ></el-image>
        <i class="el-icon-error" @click="deleteThumb(item.id)"></i>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      movie_id: this.$route.params.movie_id,
      thumbList: null, //绑定剧照列表
    };
  },
  methods: {
    //删除剧照
    deleteThumb(id) {
      this.$http.MovieThumbApi.del({ id }).then((res) => {
        console.log("删除剧照", res);
        if (res.data.code == 200) {
          this.loadThumbByMovieId();
        }
      });
    },
    loadThumbByMovieId() {
      this.$http.MovieThumbApi.listByMovieId({ movie_id: this.movie_id }).then(
        (res) => {
          console.log(res);
          this.thumbList = res.data.data;
        }
      );
    },
  },
  mounted() {
    this.loadThumbByMovieId();
  },
};
</script>

<style scoped>
.actor-item {
  display: inline-block;
  margin: 20px 20px 0px 0px;
  text-align: center;
}
.actor-item div {
  font-size: 0.9em;
}
.thumb-item {
  display: inline-block;
  position: relative;
}
.thumb-item > i {
  position: absolute;
  right: 10px;
  top: 0px;
  font-size: 1.3em;
  display: none;
  color: #000;
}
.thumb-item:hover i {
  display: block;
}
</style>